package com.example.colorpickdemo;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;

import com.example.colorpickdemo.runtime.RT;
import com.example.colorpickdemo.util.ProcessUtil;
import com.mt.sdk.ble.MTBLEManager;
import com.mt.sdk.help.MTColorPickHelper;
import com.tencent.bugly.crashreport.CrashReport;
import com.umeng.commonsdk.UMConfigure;

/**
 * Created by daiguangtao on 2020/05/30.
 */

public class ColorPickDemoApplication extends Application {

    // 初始化数据
    private MTColorPickHelper mMTColorPickHelper;
    private static boolean strictModeAvailable;

    @Override
    public void onCreate() {
        super.onCreate();
// 多进程情况只初始化一次
        if (ProcessUtil.isCurMainProcess(getApplicationContext())) {
            RT.application = this;
        }
        getDatas();
        initBLE();
        initUM();
    }

    //退出app
    public void exit() {
        android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(0);
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        keepFontSize(base);
    }

    @Override
    public void onTrimMemory(int level) {
        super.onTrimMemory(level);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }
    // 初始化数据
    private void getDatas() {
        mMTColorPickHelper = MTColorPickHelper.getinstance();
    }
    // 初始化蓝牙
    private void initBLE() {
        mMTColorPickHelper.setBleManger(MTBLEManager.getInstance(getApplicationContext()));
    }

    private void keepFontSize(Context base) {

    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        keepFontSize(this);
    }

    // 初始化友盟
    private void initUM() {
        UMConfigure.init(this,"640150beba6a5259c40fbdc1","Umeng",UMConfigure.DEVICE_TYPE_PHONE,"");
        UMConfigure.setLogEnabled(true);
        CrashReport.initCrashReport(getApplicationContext());
    }
}
